package com.lmf.controller;

import com.lmf.resultCode.R;
import com.lmf.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@CrossOrigin    //解决跨域问题
@Api(description = "阿里云管理器")
@RestController
@RequestMapping("/edu_oss/fileoss")
public class OssController {

    @Autowired
    private OssService ossService;


    @ApiOperation("文件上传")
    @PostMapping("/upload")
    public R uploadOssFile(MultipartFile file){
        //上传文件头像
        String url = ossService.uploadFileAvatar(file);
        return R.ok().data("url",url).message("文件上传成功！");
    }
}
